<template>
	<view class="container">
		<view class="h-bj"></view>
		<view class="content-box">
			<view class="assets-box">
				<view class="user-info" @click.stop="toPage(islogin ?'pages/user/userinfo':'pages/login/login')" >
					<image class="avatar-img"
						:src="userInfo.avatar?userInfo.avatar:'/static/images/empty-avatar.png'" mode="widthFix">
					</image>
					<view class="right">
						<view class="name">
							{{getShowName()}}
						</view>
					</view>
				</view>
				<view class="item-box">
					<view class="item" @click.stop="toPage('pages/UserAnswerList/UserAnswerList')">
						<text class="iconfont icondingdan_huaban"></text>
						<view>刷题记录</view>
					</view>
					<view class="border"></view>
					<view class="item" @click.stop="toPage('pages/report/report')">
						<text class="iconfont icondingdan_huaban"></text>
						<view>刷题结果</view>
					</view>
				</view>
			</view>
		</view>
		<view class="content-box">
			<view class="box tool-box">
				<view class="cell-header">
					<view class="cell-title">我的订单</view>
				</view>
				<view class="order-list flex-wrap">
					<view class="tool-item" @click.stop="toPage('pages/course/courseRecord')">
						<view class="tool-icon iconfont iconqianbao"></view>
						<view class="tool-text">待支付</view>
					</view>

					<view class="tool-item" @click.stop="toPage('pages/teacher/classTeacherList')">
						<view class="tool-icon iconfont icontuikuanshouhou"></view>
						<view class="tool-text">已支付</view>
					</view>

					<view class="tool-item" @click.stop="toPage('pages/teacher/classTeacherList')">
						<view class="tool-icon iconfont icontuikuanshouhou"></view>
						<view class="tool-text">已退款</view>
					</view>

				</view>

			</view>
			<view class="box tool-box">
				<view class="cell-header">
					<view class="cell-title">服务</view>
				</view>
				<view class="order-list flex-wrap">
					<view class="tool-item" @click.stop="toPage('pages/order/list')" v-if="!isVerify">
						<view class="tool-icon iconfont icondingdan_huaban"></view>
						<view class="tool-text">课时订单</view>
					</view>
					<view class="tool-item" @click.stop="toPage('pages/student/list')">
						<view class="tool-icon iconfont iconhuiyuan"></view>
						<view class="tool-text">学员信息</view>
					</view>
					<view class="tool-item" @click.stop="toPage('pages/feedback/platformFeedback')">
						<view class="tool-icon iconfont iconyoujian1"></view>
						<view class="tool-text">校长信箱</view>
					</view>
					<view class="tool-item" @click.stop="toPage('pages/order/cacelOrder')">
						<view class="tool-icon iconfont icontuikuanshouhou"></view>
						<view class="tool-text">退费记录</view>
					</view>
				</view>

			</view>
			<view class="box tool-box">
				<view class="cell-header">
					<view class="cell-title">其他</view>
				</view>
				<view class="order-list flex-wrap">
					<view class="tool-item" @click.stop="toPage('pages/order/editAddress')">
						<view class="tool-icon iconfont iconshezhi2"></view>
						<view class="tool-text">设置</view>
					</view>
					<button class="tool-item" open-type="contact" hover-class="opcity" :hover-stay-time="150">
						<view class="tool-item" style="width: 172rpx;">
							<view class="tool-icon iconfont iconicon_kefu"></view>
							<view class="tool-text">客服服务</view>
						</view>
					</button>
					<view class="tool-item" style="width: 172rpx;"
						@click.stop="$tools.toPage('pages/parse/parse?title=教育服务协议&k=key&val=courseAgreement&url='+$urls.parseInfo)">
						<view class="tool-icon iconfont iconlianjie"></view>
						<view class="tool-text">教育协议</view>
					</view>
					<view class="tool-item" v-if="!isVerify" @click.stop="toPage('pages/mall/menu')">
						<view class="tool-icon iconfont icondianpu1"></view>
						<view class="tool-text">小风币兑换</view>
					</view>
					<view class="tool-item" @click.stop="toPage('pages/mySpread/list')">
						<view class="tool-icon iconfont iconyonghuguanli_huaban"></view>
						<view class="tool-text">我的推广</view>
					</view>
					<view class="tool-item" v-if="!isVerify" @click.stop="toPage('pages/mySpread/myBonus')">
						<view class="tool-icon iconfont iconRectangleCopy"></view>
						<view class="tool-text">我的小风币</view>
					</view>
				</view>

			</view>
			<view v-if="islogin" class='logout' @click.stop='logout'>退出登录</view>
		</view>

		<view style="height: 100rpx;"></view>
		<tabbar />
	</view>
</template>

<script>
	import {
		getUserInfo
	} from '@/utils/api/user_info.js';
	import tabbar from "@/components/tabbar"
	export default {
		components: {
			tabbar,
		},
		data() {
			return {
				isVerify: 0,
				userInfo: {},
				phone: '',
				name: '',
				nickname: '',
				avatar: '',
				surplusCourseTime: 0,
				consumeCourseTime: 0,
				surplusCoursePrice: 0,
				order: {
					fa: 0,
					shou: 0,
					wan: 0
				},
				islogin: false,
			}
		},
		onLoad() {
			this.GetUserInfo()
		},
		onShow() {},
		methods: {
			UserAnswerList() {
				//跳转用户刷题记录的接口
				uni.navigateTo({
					url: "/pages/UserAnswerList/UserAnswerList"
				});
				
			},
			
			Report(){
        //跳转掌握率与未掌握率报告接口
				uni.navigateTo({
					url:"/pages/report/report"
				})
			},
			getShowName() {
				if (this.name) return this.name;
				if (this.userInfo.nickname) return this.userInfo.nickname;
				return '点击登录'
			},
			async getMineData() {
				let res = await this.$tools.req(this.$urls.getMineData)
				if (res.code == 200) {
					this.name = res.data.name ? res.data.name : ''
					this.consumeCourseTime = res.data.consumeCourseTime
					this.surplusCourseTime = res.data.surplusCourseTime
					this.surplusCoursePrice = res.data.surplusCoursePrice
				}
			},
			logout() {
				uni.setStorageSync('token','')		
				uni.removeStorageSync('userInfo')
				uni.reLaunch({
					url: '/pages/mine/mine'
				})
			},
			GetUserInfo() {
				getUserInfo({from:""}).then(res => {
						if (res.data.code != 0) {
							return
						}
						this.islogin = true
						this.userInfo =  res.data.data
					});
			},
			async toPage(url) {
				this.$tools.toPage(url)
			},
		},
		mounted() {
			
		}

	}
</script>

<style scoped lang="scss">
	button::after {
		border: none !important;
		padding: 0 !important;
		margin: 0 !important;
	}

	button {
		background-color: transparent !important;
		padding: 0 !important;
		line-height: inherit !important;
		margin: 0 !important;
		width: auto !important;
		font-weight: 500 !important;
		border-radius: 1px !important;
	}

	page {
		background: #f8f8f8;
		overflow-x: hidden !important;
	}

	.h-bj {
		height: 50rpx;
		background: $themeColor;
	}

	.content-box {
		padding: 0 30rpx;
		box-sizing: border-box;
		position: relative;
		top: -72rpx;
		z-index: 10;

		.assets-box {
			padding: 35rpx 20rpx;
			background: #fff;
			box-shadow: 0 3rpx 20rpx rgba(183, 183, 183, 0.1);
			border-radius: 10rpx;
			margin-top: 20rpx;
		}

		.user-info {
			width: 90%;
			display: flex;
			justify-content: space-between;

			.avatar-img {
				width: 120rpx;
				border-radius: 10%;
				background: #eee;
			}

			.right {
				margin-left: 15rpx;
				width: 90%;
				font-size: 30rpx;
			}

			.name {
				color: #333;
			}

			.show {
				margin-top: 10rpx;
				color: #888;
				background: #f2f2f2;
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 25rpx;
				padding: 6rpx 25rpx;
				border-radius: 25rpx;

				.iconfont {
					color: #888;
					font-size: 20rpx;
				}
			}
		}

		.item-box {
			margin-top: 30rpx;
			display: flex;
			align-items: center;
			justify-content: space-around;
			color: #666;
			font-size: 26rpx;

			.item {
				display: flex;
				align-items: center;

				view {
					margin-left: 20rpx;
					line-height: 40rpx;
				}
			}

			.border {
				width: 2rpx;
				height: 36rpx;
				background: #888;
			}
		}
	}

	.logout {
		text-align: center;
		background: #fff;
		padding: 25rpx 0;
		color: #333;
		margin-top: 50rpx;
	}

	.header-box {
		width: 100%;
		padding: 0 30rpx 0 20rpx;
		box-sizing: border-box;
		position: fixed;
		top: 0;
		left: 0;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		height: 32px;
		transform: translateZ(0);
		z-index: 9999;
	}

	.icon-box {
		position: relative;
	}

	.icon-setup {
		margin-left: 8rpx;
	}

	.badge {
		position: absolute;
		font-size: 24rpx;
		height: 32rpx;
		min-width: 20rpx;
		padding: 0 6rpx;
		border-radius: 40rpx;
		right: 0;
		top: -10rpx;
		transform: scale(0.8) translateX(60%);
		transform-origin: center center;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 10;
	}

	.badge-red {
		background: $themeColor;
		color: #fff;
	}

	.badge-white {
		background: #fff;
		color: #2ba245;
	}

	.mybg-box {
		width: 100%;
		height: 300rpx;
		position: relative;
	}

	.top-bj {
		position: absolute;
		top: 0;
		left: 0;
		height: 320rpx;
		width: 100%;
		background: $themeColor;
	}

	.my-bg {
		width: 100%;
		height: 464rpx;
		display: block;
	}

	.header-center {
		position: absolute;
		width: 100%;
		height: 128rpx;
		left: 0;
		top: 50rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
	}

	.avatar {
		width: 128rpx;
		height: 128rpx;
		border-radius: 50%;
	}

	.info {
		width: 60%;
		padding-left: 30rpx;

	}

	.nickname {
		font-size: 35rpx;
		font-weight: 500;
		color: #fff;
		display: flex;
		align-items: center;
	}

	.img-vip {
		width: 56rpx;
		height: 24rpx;
		margin-left: 18rpx;
	}

	.explain {
		width: 60%;
		font-size: 24rpx;
		font-weight: 400;
		color: #fff;
		opacity: 0.75;
		padding-top: 8rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.tips {
		font-size: 28rpx;
		color: #fff;
		padding-right: 22rpx;
	}

	.header-btm {
		width: 100%;
		padding: 0 30rpx;
		box-sizing: border-box;
		position: absolute;
		left: 0;
		top: 280rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		color: #fff;
	}

	.btm-item {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.btm-num {
		font-size: 32rpx;
		font-weight: 600;
		position: relative;
	}

	.btm-text {
		font-size: 24rpx;
		opacity: 0.85;
		padding-top: 4rpx;
	}

	.content-box {
		width: 100%;
		padding: 0 30rpx;
		box-sizing: border-box;
		position: relative;
		top: -72rpx;
		z-index: 10;
	}

	.box {
		width: 100%;
		background: #fff;
		box-shadow: 0 3rpx 20rpx rgba(183, 183, 183, 0.1);
		border-radius: 10rpx;
		overflow: hidden;
	}

	.order-box {
		height: 208rpx;
		margin-top: 20rpx;
	}

	.cell-header {
		width: 100%;
		height: 74rpx;
		padding: 0 26rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-bottom: 1rpx #eee dashed;
	}

	.cell-title {
		font-size: 30rpx;
		line-height: 30rpx;
		font-weight: 600;
		color: #333;
	}

	.cell-sub {
		font-size: 26rpx;
		font-weight: 400;
		color: #666;
	}

	.cell-sub text {
		font-size: 24rpx;
	}

	.order-list {
		width: 100%;
		height: 134rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
	}

	.order-item {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.order-text,
	.tool-text {
		font-size: 24rpx;
		font-weight: 400;
		color: #555;
		padding-top: 4rpx;
	}

	.tool-text {
		margin-top: 10rpx;
		font-size: 24rpx;
	}

	.order-icon {
		font-size: 56rpx;
		color: #888;
	}

	.assets-box {
		margin-top: 20rpx;
	}

	.assets-list {
		height: 75rpx;
		display: flex;
		align-items: center;
		padding: 35rpx 0;
	}

	.assets-num {
		font-size: 44rpx;
		color: $themeColor;
		position: relative;
	}

	.assets-text {
		font-size: 28rpx;
		font-weight: 400;
		color: #666;
		padding-top: 6rpx;
	}

	.tool-box {
		margin-top: 20rpx;
	}

	.flex-wrap {
		flex-wrap: wrap;
		height: auto;
		padding-bottom: 30rpx;
	}

	.tool-item {
		width: 25%;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		padding-top: 30rpx;
	}

	.tool-icon {
		font-size: 50rpx;
		color: #888;
	}
</style>